// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

#![allow(rustdoc::redundant_explicit_links)]
#![allow(rustdoc::broken_intra_doc_links)]
#![no_implicit_prelude]
extern crate async_trait;
extern crate bytes;
extern crate gax;
extern crate gaxi;
extern crate lazy_static;
extern crate location;
extern crate reqwest;
extern crate serde;
extern crate serde_json;
extern crate serde_with;
extern crate std;
extern crate tracing;
extern crate wkt;

mod debug;
mod deserialize;
mod serialize;

/// Request message for SummarizeMaintenances custom method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SummarizeMaintenancesRequest {
    /// Required. The parent of the resource maintenance.
    /// eg. `projects/123/locations/*`
    pub parent: std::string::String,

    /// The maximum number of resource maintenances to send per page. The default
    /// page size is 20 and the maximum is 1000.
    pub page_size: i32,

    /// The page token: If the next_page_token from a previous response
    /// is provided, this request will send the subsequent page.
    pub page_token: std::string::String,

    /// Filter the list as specified in <https://google.aip.dev/160>.
    /// Supported fields include:
    ///
    /// - `state`
    /// - `resource.location`
    /// - `resource.resourceName`
    /// - `resource.type`
    /// - `maintenance.maintenanceName`
    /// - `maintenanceStartTime`
    /// - `maintenanceCompleteTime`
    ///   Examples:
    /// - `state="SCHEDULED"`
    /// - `resource.location="us-central1-c"`
    /// - `resource.resourceName=~"*/instance-20241212-211259"`
    /// - `maintenanceStartTime>"2000-10-11T20:44:51Z"`
    /// - `state="SCHEDULED" OR resource.type="compute.googleapis.com/Instance"`
    /// - `maintenance.maitenanceName="eb3b709c-9ca1-5472-9fb6-800a3849eda1" AND
    ///   maintenanceCompleteTime>"2000-10-11T20:44:51Z"`
    pub filter: std::string::String,

    /// Order results as specified in <https://google.aip.dev/132>.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SummarizeMaintenancesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::SummarizeMaintenancesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::SummarizeMaintenancesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::SummarizeMaintenancesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::SummarizeMaintenancesRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::SummarizeMaintenancesRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for SummarizeMaintenancesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.SummarizeMaintenancesRequest"
    }
}

/// Request message for SummarizeMaintenances custom method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct SummarizeMaintenancesResponse {
    /// The resulting summaries.
    pub maintenances: std::vec::Vec<crate::model::MaintenanceSummary>,

    /// If present, the next page token can be provided to a subsequent
    /// SummarizeMaintenances call to list the next page.
    /// If empty, there are no more pages.
    pub next_page_token: std::string::String,

    /// Unordered list. Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl SummarizeMaintenancesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [maintenances][crate::model::SummarizeMaintenancesResponse::maintenances].
    pub fn set_maintenances<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MaintenanceSummary>,
    {
        use std::iter::Iterator;
        self.maintenances = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::SummarizeMaintenancesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::SummarizeMaintenancesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for SummarizeMaintenancesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.SummarizeMaintenancesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for SummarizeMaintenancesResponse {
    type PageItem = crate::model::MaintenanceSummary;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.maintenances
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// MaintenanceSummary contains maintenance statistics calculated based on
/// ResourceMaintenances within the scope: project and location.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MaintenanceSummary {
    /// Output only. The name of the maintenance.
    pub maintenance_name: std::string::String,

    /// Output only. The title of the maintenance.
    pub title: std::string::String,

    /// Output only. The description of the maintenance.
    pub description: std::string::String,

    /// Output only. The category of the maintenance event.
    pub category: crate::model::MaintenanceCategory,

    /// Output only. Scheduled start time of the maintenance. The maintenance will
    /// start at `maintenanceScheduledStartTime` or later, with best effort to
    /// finish before `maintenanceScheduledEndTime`.
    pub maintenance_scheduled_start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. An estimated (best effort, not guaranteed) end time of the
    /// scheduled maintenance.
    pub maintenance_scheduled_end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Actual date when the maintenance started. Field present only
    /// after the state changed to `RUNNING`.
    pub maintenance_start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Actual date when the maintenance successfully completed. Field
    /// present only after the state changed to `SUCCEEDED`.
    pub maintenance_end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Indicates whether the user has some control over that
    /// maintenance, either proactively before maintenance was scheduled with
    /// maintenance policy or with reactive controls after it was scheduled (see
    /// controls field).
    pub user_controllable: bool,

    /// Output only. Control available for that Maintenance (might not be available
    /// for every resource that maintenance is applied to).
    pub controls: std::vec::Vec<crate::model::MaintenanceControl>,

    /// Output only. Stats is a field of ResourceMaintenance used to aggregate the
    /// stats.
    pub stats: std::vec::Vec<crate::model::maintenance_summary::Stats>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MaintenanceSummary {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [maintenance_name][crate::model::MaintenanceSummary::maintenance_name].
    pub fn set_maintenance_name<T: std::convert::Into<std::string::String>>(
        mut self,
        v: T,
    ) -> Self {
        self.maintenance_name = v.into();
        self
    }

    /// Sets the value of [title][crate::model::MaintenanceSummary::title].
    pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.title = v.into();
        self
    }

    /// Sets the value of [description][crate::model::MaintenanceSummary::description].
    pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.description = v.into();
        self
    }

    /// Sets the value of [category][crate::model::MaintenanceSummary::category].
    pub fn set_category<T: std::convert::Into<crate::model::MaintenanceCategory>>(
        mut self,
        v: T,
    ) -> Self {
        self.category = v.into();
        self
    }

    /// Sets the value of [maintenance_scheduled_start_time][crate::model::MaintenanceSummary::maintenance_scheduled_start_time].
    pub fn set_maintenance_scheduled_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_scheduled_start_time][crate::model::MaintenanceSummary::maintenance_scheduled_start_time].
    pub fn set_or_clear_maintenance_scheduled_start_time<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_scheduled_end_time][crate::model::MaintenanceSummary::maintenance_scheduled_end_time].
    pub fn set_maintenance_scheduled_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_scheduled_end_time][crate::model::MaintenanceSummary::maintenance_scheduled_end_time].
    pub fn set_or_clear_maintenance_scheduled_end_time<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_start_time][crate::model::MaintenanceSummary::maintenance_start_time].
    pub fn set_maintenance_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_start_time][crate::model::MaintenanceSummary::maintenance_start_time].
    pub fn set_or_clear_maintenance_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_end_time][crate::model::MaintenanceSummary::maintenance_end_time].
    pub fn set_maintenance_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_end_time][crate::model::MaintenanceSummary::maintenance_end_time].
    pub fn set_or_clear_maintenance_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [user_controllable][crate::model::MaintenanceSummary::user_controllable].
    pub fn set_user_controllable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.user_controllable = v.into();
        self
    }

    /// Sets the value of [controls][crate::model::MaintenanceSummary::controls].
    pub fn set_controls<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MaintenanceControl>,
    {
        use std::iter::Iterator;
        self.controls = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [stats][crate::model::MaintenanceSummary::stats].
    pub fn set_stats<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::maintenance_summary::Stats>,
    {
        use std::iter::Iterator;
        self.stats = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for MaintenanceSummary {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.MaintenanceSummary"
    }
}

/// Defines additional types related to [MaintenanceSummary].
pub mod maintenance_summary {
    #[allow(unused_imports)]
    use super::*;

    /// Stats indicates the type of aggregate and the corresponding aggregates.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Stats {
        /// groupBy specifies the type of aggregate.
        /// For example a group_by might be `"state"`
        pub group_by: std::string::String,

        /// Aggregates is a list <group, count> pairs. For example, if the
        /// group_by is `"state"` a possible tuple in the aggregates list could be
        /// "SCHEDULED" : `11`,
        pub aggregates: std::vec::Vec<crate::model::maintenance_summary::Aggregate>,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Stats {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [group_by][crate::model::maintenance_summary::Stats::group_by].
        pub fn set_group_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.group_by = v.into();
            self
        }

        /// Sets the value of [aggregates][crate::model::maintenance_summary::Stats::aggregates].
        pub fn set_aggregates<T, V>(mut self, v: T) -> Self
        where
            T: std::iter::IntoIterator<Item = V>,
            V: std::convert::Into<crate::model::maintenance_summary::Aggregate>,
        {
            use std::iter::Iterator;
            self.aggregates = v.into_iter().map(|i| i.into()).collect();
            self
        }
    }

    impl wkt::message::Message for Stats {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.maintenance.api.v1.MaintenanceSummary.Stats"
        }
    }

    /// Aggregate is a <group, count> pair.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Aggregate {
        /// Specifies what specific value of the group_by the count represents. For
        /// example if group_by is `"state"` its corresponding group could be
        /// `"SCHEDULED"`.
        pub group: std::string::String,

        /// The count of the group.
        pub count: i64,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Aggregate {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [group][crate::model::maintenance_summary::Aggregate::group].
        pub fn set_group<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.group = v.into();
            self
        }

        /// Sets the value of [count][crate::model::maintenance_summary::Aggregate::count].
        pub fn set_count<T: std::convert::Into<i64>>(mut self, v: T) -> Self {
            self.count = v.into();
            self
        }
    }

    impl wkt::message::Message for Aggregate {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.maintenance.api.v1.MaintenanceSummary.Aggregate"
        }
    }
}

/// ResourceMaintenance is a resource that represents a maintenance operation
/// on a resource.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ResourceMaintenance {
    /// Identifier. The name of the resource_maintenance resource.
    /// Format:
    /// `"projects/{project}/locations/{location}/resourceMaintenance/{resource-maintenance-id}"`
    pub name: std::string::String,

    /// Output only. The resource spec of the resource maintenance.
    pub resource: std::option::Option<crate::model::resource_maintenance::Resource>,

    /// Output only. The details of the maintenance.
    pub maintenance: std::option::Option<crate::model::resource_maintenance::Maintenance>,

    /// Output only. The state of the resource maintenance.
    pub state: crate::model::resource_maintenance::State,

    /// Output only. The create time of the resource maintenance.
    pub create_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The update time of the resource maintenance.
    pub update_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when the resource maintenance has started.
    pub maintenance_start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when the resource maintenance has completed.
    pub maintenance_end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when the resource maintenance was cancelled.
    pub maintenance_cancel_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when the maintenance on the resource was scheduled to
    /// start.
    pub maintenance_scheduled_start_time: std::option::Option<wkt::Timestamp>,

    /// Output only. The time when the maintenance on the resource was scheduled to
    /// end.
    pub maintenance_scheduled_end_time: std::option::Option<wkt::Timestamp>,

    /// Output only. Indicates whether the user has some control over that
    /// maintenance, either proactively before maintenance was scheduled with
    /// maintenance policy or with reactive controls after it was scheduled (see
    /// controls field)
    pub user_controllable: bool,

    /// Output only. The controls of the maintenance.
    pub controls: std::vec::Vec<crate::model::MaintenanceControl>,

    /// Optional. The labels on the resource, which can be used for categorization.
    /// similar to Kubernetes resource labels.
    pub labels: std::collections::HashMap<std::string::String, std::string::String>,

    /// Optional. Annotations is an unstructured key-value map stored with a
    /// resource that may be set by external tools to store and retrieve arbitrary
    /// metadata. They are not queryable and should be preserved when modifying
    /// objects.
    ///
    /// More info: <https://kubernetes.io/docs/user-guide/annotations>
    pub annotations: std::collections::HashMap<std::string::String, std::string::String>,

    /// Output only. The unique identifier of the resource. UID is unique in the
    /// time and space for this resource within the scope of the service. It is
    /// typically generated by the server on successful creation of a resource
    /// and must not be changed. UID is used to uniquely identify resources
    /// with resource name reuses. This should be a UUID4.
    pub uid: std::string::String,

    /// Output only. An opaque value that uniquely identifies a version or
    /// generation of a resource. It can be used to confirm that the client
    /// and server agree on the ordering of a resource being written.
    pub etag: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ResourceMaintenance {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::ResourceMaintenance::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }

    /// Sets the value of [resource][crate::model::ResourceMaintenance::resource].
    pub fn set_resource<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::resource_maintenance::Resource>,
    {
        self.resource = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [resource][crate::model::ResourceMaintenance::resource].
    pub fn set_or_clear_resource<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::resource_maintenance::Resource>,
    {
        self.resource = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance][crate::model::ResourceMaintenance::maintenance].
    pub fn set_maintenance<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<crate::model::resource_maintenance::Maintenance>,
    {
        self.maintenance = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance][crate::model::ResourceMaintenance::maintenance].
    pub fn set_or_clear_maintenance<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<crate::model::resource_maintenance::Maintenance>,
    {
        self.maintenance = v.map(|x| x.into());
        self
    }

    /// Sets the value of [state][crate::model::ResourceMaintenance::state].
    pub fn set_state<T: std::convert::Into<crate::model::resource_maintenance::State>>(
        mut self,
        v: T,
    ) -> Self {
        self.state = v.into();
        self
    }

    /// Sets the value of [create_time][crate::model::ResourceMaintenance::create_time].
    pub fn set_create_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [create_time][crate::model::ResourceMaintenance::create_time].
    pub fn set_or_clear_create_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.create_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [update_time][crate::model::ResourceMaintenance::update_time].
    pub fn set_update_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [update_time][crate::model::ResourceMaintenance::update_time].
    pub fn set_or_clear_update_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.update_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_start_time][crate::model::ResourceMaintenance::maintenance_start_time].
    pub fn set_maintenance_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_start_time][crate::model::ResourceMaintenance::maintenance_start_time].
    pub fn set_or_clear_maintenance_start_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_end_time][crate::model::ResourceMaintenance::maintenance_end_time].
    pub fn set_maintenance_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_end_time][crate::model::ResourceMaintenance::maintenance_end_time].
    pub fn set_or_clear_maintenance_end_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_cancel_time][crate::model::ResourceMaintenance::maintenance_cancel_time].
    pub fn set_maintenance_cancel_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_cancel_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_cancel_time][crate::model::ResourceMaintenance::maintenance_cancel_time].
    pub fn set_or_clear_maintenance_cancel_time<T>(mut self, v: std::option::Option<T>) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_cancel_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_scheduled_start_time][crate::model::ResourceMaintenance::maintenance_scheduled_start_time].
    pub fn set_maintenance_scheduled_start_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_start_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_scheduled_start_time][crate::model::ResourceMaintenance::maintenance_scheduled_start_time].
    pub fn set_or_clear_maintenance_scheduled_start_time<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_start_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [maintenance_scheduled_end_time][crate::model::ResourceMaintenance::maintenance_scheduled_end_time].
    pub fn set_maintenance_scheduled_end_time<T>(mut self, v: T) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_end_time = std::option::Option::Some(v.into());
        self
    }

    /// Sets or clears the value of [maintenance_scheduled_end_time][crate::model::ResourceMaintenance::maintenance_scheduled_end_time].
    pub fn set_or_clear_maintenance_scheduled_end_time<T>(
        mut self,
        v: std::option::Option<T>,
    ) -> Self
    where
        T: std::convert::Into<wkt::Timestamp>,
    {
        self.maintenance_scheduled_end_time = v.map(|x| x.into());
        self
    }

    /// Sets the value of [user_controllable][crate::model::ResourceMaintenance::user_controllable].
    pub fn set_user_controllable<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.user_controllable = v.into();
        self
    }

    /// Sets the value of [controls][crate::model::ResourceMaintenance::controls].
    pub fn set_controls<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::MaintenanceControl>,
    {
        use std::iter::Iterator;
        self.controls = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [labels][crate::model::ResourceMaintenance::labels].
    pub fn set_labels<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [annotations][crate::model::ResourceMaintenance::annotations].
    pub fn set_annotations<T, K, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = (K, V)>,
        K: std::convert::Into<std::string::String>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.annotations = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect();
        self
    }

    /// Sets the value of [uid][crate::model::ResourceMaintenance::uid].
    pub fn set_uid<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.uid = v.into();
        self
    }

    /// Sets the value of [etag][crate::model::ResourceMaintenance::etag].
    pub fn set_etag<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.etag = v.into();
        self
    }
}

impl wkt::message::Message for ResourceMaintenance {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.ResourceMaintenance"
    }
}

/// Defines additional types related to [ResourceMaintenance].
pub mod resource_maintenance {
    #[allow(unused_imports)]
    use super::*;

    /// Resource contains information about the resource affected by maintenance.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Resource {
        /// Output only. Name is the reference to the consumer resource affected by
        /// the maintenance. Available values can be found here:
        /// <https://cloud.google.com/asset-inventory/docs/asset-names>
        pub resource_name: std::string::String,

        /// Output only. The location of the resource.
        /// Format:
        /// `us-central1`
        pub location: std::string::String,

        /// Output only. The type of the resource.
        /// Available values can be found here:
        /// <https://cloud.google.com/asset-inventory/docs/asset-types#supported_resource_types>
        /// Please note that not all the resource types will have their maintenances
        /// reported.
        pub r#type: std::string::String,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Resource {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [resource_name][crate::model::resource_maintenance::Resource::resource_name].
        pub fn set_resource_name<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.resource_name = v.into();
            self
        }

        /// Sets the value of [location][crate::model::resource_maintenance::Resource::location].
        pub fn set_location<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.location = v.into();
            self
        }

        /// Sets the value of [r#type][crate::model::resource_maintenance::Resource::type].
        pub fn set_type<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.r#type = v.into();
            self
        }
    }

    impl wkt::message::Message for Resource {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.maintenance.api.v1.ResourceMaintenance.Resource"
        }
    }

    /// Maintenance is the maintenance details of a resource's maintenance.
    #[derive(Clone, Default, PartialEq)]
    #[non_exhaustive]
    pub struct Maintenance {
        /// Maintenance is the name of the corresponding maintenance resource
        /// following the standard naming scheme: `"{maintenance-id}"`
        pub maintenance_name: std::string::String,

        /// Output only. The title of the maintenance.
        pub title: std::string::String,

        /// Output only. The description of the maintenance.
        pub description: std::string::String,

        /// Output only. The category of the maintenance.
        pub category: crate::model::MaintenanceCategory,

        pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
    }

    impl Maintenance {
        pub fn new() -> Self {
            std::default::Default::default()
        }

        /// Sets the value of [maintenance_name][crate::model::resource_maintenance::Maintenance::maintenance_name].
        pub fn set_maintenance_name<T: std::convert::Into<std::string::String>>(
            mut self,
            v: T,
        ) -> Self {
            self.maintenance_name = v.into();
            self
        }

        /// Sets the value of [title][crate::model::resource_maintenance::Maintenance::title].
        pub fn set_title<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.title = v.into();
            self
        }

        /// Sets the value of [description][crate::model::resource_maintenance::Maintenance::description].
        pub fn set_description<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
            self.description = v.into();
            self
        }

        /// Sets the value of [category][crate::model::resource_maintenance::Maintenance::category].
        pub fn set_category<T: std::convert::Into<crate::model::MaintenanceCategory>>(
            mut self,
            v: T,
        ) -> Self {
            self.category = v.into();
            self
        }
    }

    impl wkt::message::Message for Maintenance {
        fn typename() -> &'static str {
            "type.googleapis.com/google.cloud.maintenance.api.v1.ResourceMaintenance.Maintenance"
        }
    }

    /// State is the state of a resource maintenance.
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum State {
        /// Unspecified state.
        Unspecified,
        /// Scheduled for a particular window. For disruptive maintenance it should
        /// respect maintenance policy, i.e. its available windows, exclusions and
        /// notification period.
        Scheduled,
        /// Maintenance is ongoing.
        Running,
        /// No longer planned, typically when other maintenance (e.g. upgrade to
        /// newer version) already happened, or the user skipped the maintenance.
        Cancelled,
        /// Successfully completed.
        Succeeded,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [State::value] or
        /// [State::name].
        UnknownValue(state::UnknownValue),
    }

    #[doc(hidden)]
    pub mod state {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl State {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Scheduled => std::option::Option::Some(1),
                Self::Running => std::option::Option::Some(2),
                Self::Cancelled => std::option::Option::Some(3),
                Self::Succeeded => std::option::Option::Some(4),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("STATE_UNSPECIFIED"),
                Self::Scheduled => std::option::Option::Some("SCHEDULED"),
                Self::Running => std::option::Option::Some("RUNNING"),
                Self::Cancelled => std::option::Option::Some("CANCELLED"),
                Self::Succeeded => std::option::Option::Some("SUCCEEDED"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for State {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for State {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for State {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Scheduled,
                2 => Self::Running,
                3 => Self::Cancelled,
                4 => Self::Succeeded,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for State {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "STATE_UNSPECIFIED" => Self::Unspecified,
                "SCHEDULED" => Self::Scheduled,
                "RUNNING" => Self::Running,
                "CANCELLED" => Self::Cancelled,
                "SUCCEEDED" => Self::Succeeded,
                _ => Self::UnknownValue(state::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for State {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Scheduled => serializer.serialize_i32(1),
                Self::Running => serializer.serialize_i32(2),
                Self::Cancelled => serializer.serialize_i32(3),
                Self::Succeeded => serializer.serialize_i32(4),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for State {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<State>::new(
                ".google.cloud.maintenance.api.v1.ResourceMaintenance.State",
            ))
        }
    }
}

/// The control of the maintenance.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct MaintenanceControl {
    /// The control of the resource maintenance.
    pub control: crate::model::maintenance_control::Control,

    /// Indicates whether the control is available only in Service Producer API
    /// (not through Unified Maintenance).
    pub is_custom: bool,

    /// Link to Service Producer documentation about maintenance control. Provided
    /// only when `isCustom` is `true`.
    pub documentation: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl MaintenanceControl {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [control][crate::model::MaintenanceControl::control].
    pub fn set_control<T: std::convert::Into<crate::model::maintenance_control::Control>>(
        mut self,
        v: T,
    ) -> Self {
        self.control = v.into();
        self
    }

    /// Sets the value of [is_custom][crate::model::MaintenanceControl::is_custom].
    pub fn set_is_custom<T: std::convert::Into<bool>>(mut self, v: T) -> Self {
        self.is_custom = v.into();
        self
    }

    /// Sets the value of [documentation][crate::model::MaintenanceControl::documentation].
    pub fn set_documentation<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.documentation = v.into();
        self
    }
}

impl wkt::message::Message for MaintenanceControl {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.MaintenanceControl"
    }
}

/// Defines additional types related to [MaintenanceControl].
pub mod maintenance_control {
    #[allow(unused_imports)]
    use super::*;

    /// Sets the type of control supported. comment (as in logs).
    ///
    /// # Working with unknown values
    ///
    /// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
    /// additional enum variants at any time. Adding new variants is not considered
    /// a breaking change. Applications should write their code in anticipation of:
    ///
    /// - New values appearing in future releases of the client library, **and**
    /// - New values received dynamically, without application changes.
    ///
    /// Please consult the [Working with enums] section in the user guide for some
    /// guidelines.
    ///
    /// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
    #[derive(Clone, Debug, PartialEq)]
    #[non_exhaustive]
    pub enum Control {
        /// Unspecified control.
        Unspecified,
        /// Apply control.
        Apply,
        /// Manage policy control.
        ManagePolicy,
        /// Reschedule control.
        Reschedule,
        /// If set, the enum was initialized with an unknown value.
        ///
        /// Applications can examine the value using [Control::value] or
        /// [Control::name].
        UnknownValue(control::UnknownValue),
    }

    #[doc(hidden)]
    pub mod control {
        #[allow(unused_imports)]
        use super::*;
        #[derive(Clone, Debug, PartialEq)]
        pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
    }

    impl Control {
        /// Gets the enum value.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the string representation of enums.
        pub fn value(&self) -> std::option::Option<i32> {
            match self {
                Self::Unspecified => std::option::Option::Some(0),
                Self::Apply => std::option::Option::Some(1),
                Self::ManagePolicy => std::option::Option::Some(2),
                Self::Reschedule => std::option::Option::Some(3),
                Self::UnknownValue(u) => u.0.value(),
            }
        }

        /// Gets the enum value as a string.
        ///
        /// Returns `None` if the enum contains an unknown value deserialized from
        /// the integer representation of enums.
        pub fn name(&self) -> std::option::Option<&str> {
            match self {
                Self::Unspecified => std::option::Option::Some("CONTROL_UNSPECIFIED"),
                Self::Apply => std::option::Option::Some("APPLY"),
                Self::ManagePolicy => std::option::Option::Some("MANAGE_POLICY"),
                Self::Reschedule => std::option::Option::Some("RESCHEDULE"),
                Self::UnknownValue(u) => u.0.name(),
            }
        }
    }

    impl std::default::Default for Control {
        fn default() -> Self {
            use std::convert::From;
            Self::from(0)
        }
    }

    impl std::fmt::Display for Control {
        fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
            wkt::internal::display_enum(f, self.name(), self.value())
        }
    }

    impl std::convert::From<i32> for Control {
        fn from(value: i32) -> Self {
            match value {
                0 => Self::Unspecified,
                1 => Self::Apply,
                2 => Self::ManagePolicy,
                3 => Self::Reschedule,
                _ => Self::UnknownValue(control::UnknownValue(
                    wkt::internal::UnknownEnumValue::Integer(value),
                )),
            }
        }
    }

    impl std::convert::From<&str> for Control {
        fn from(value: &str) -> Self {
            use std::string::ToString;
            match value {
                "CONTROL_UNSPECIFIED" => Self::Unspecified,
                "APPLY" => Self::Apply,
                "MANAGE_POLICY" => Self::ManagePolicy,
                "RESCHEDULE" => Self::Reschedule,
                _ => Self::UnknownValue(control::UnknownValue(
                    wkt::internal::UnknownEnumValue::String(value.to_string()),
                )),
            }
        }
    }

    impl serde::ser::Serialize for Control {
        fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
        where
            S: serde::Serializer,
        {
            match self {
                Self::Unspecified => serializer.serialize_i32(0),
                Self::Apply => serializer.serialize_i32(1),
                Self::ManagePolicy => serializer.serialize_i32(2),
                Self::Reschedule => serializer.serialize_i32(3),
                Self::UnknownValue(u) => u.0.serialize(serializer),
            }
        }
    }

    impl<'de> serde::de::Deserialize<'de> for Control {
        fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
        where
            D: serde::Deserializer<'de>,
        {
            deserializer.deserialize_any(wkt::internal::EnumVisitor::<Control>::new(
                ".google.cloud.maintenance.api.v1.MaintenanceControl.Control",
            ))
        }
    }
}

/// The request structure for the ListResourceMaintenances method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListResourceMaintenancesRequest {
    /// Required. The parent of the resource maintenance.
    pub parent: std::string::String,

    /// The maximum number of resource maintenances to send per page.
    pub page_size: i32,

    /// The page token: If the next_page_token from a previous response
    /// is provided, this request will send the subsequent page.
    pub page_token: std::string::String,

    /// Filter the list as specified in <https://google.aip.dev/160>.
    pub filter: std::string::String,

    /// Order results as specified in <https://google.aip.dev/132>.
    pub order_by: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListResourceMaintenancesRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [parent][crate::model::ListResourceMaintenancesRequest::parent].
    pub fn set_parent<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.parent = v.into();
        self
    }

    /// Sets the value of [page_size][crate::model::ListResourceMaintenancesRequest::page_size].
    pub fn set_page_size<T: std::convert::Into<i32>>(mut self, v: T) -> Self {
        self.page_size = v.into();
        self
    }

    /// Sets the value of [page_token][crate::model::ListResourceMaintenancesRequest::page_token].
    pub fn set_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.page_token = v.into();
        self
    }

    /// Sets the value of [filter][crate::model::ListResourceMaintenancesRequest::filter].
    pub fn set_filter<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.filter = v.into();
        self
    }

    /// Sets the value of [order_by][crate::model::ListResourceMaintenancesRequest::order_by].
    pub fn set_order_by<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.order_by = v.into();
        self
    }
}

impl wkt::message::Message for ListResourceMaintenancesRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.ListResourceMaintenancesRequest"
    }
}

/// The response structure for the ListResourceMaintenances method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct ListResourceMaintenancesResponse {
    /// The resulting resource maintenances.
    pub resource_maintenances: std::vec::Vec<crate::model::ResourceMaintenance>,

    /// If present, the next page token can be provided to a subsequent
    /// ListResourceMaintenances call to list the next page.
    /// If empty, there are no more pages.
    pub next_page_token: std::string::String,

    /// Locations that could not be reached.
    pub unreachable: std::vec::Vec<std::string::String>,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl ListResourceMaintenancesResponse {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [resource_maintenances][crate::model::ListResourceMaintenancesResponse::resource_maintenances].
    pub fn set_resource_maintenances<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<crate::model::ResourceMaintenance>,
    {
        use std::iter::Iterator;
        self.resource_maintenances = v.into_iter().map(|i| i.into()).collect();
        self
    }

    /// Sets the value of [next_page_token][crate::model::ListResourceMaintenancesResponse::next_page_token].
    pub fn set_next_page_token<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.next_page_token = v.into();
        self
    }

    /// Sets the value of [unreachable][crate::model::ListResourceMaintenancesResponse::unreachable].
    pub fn set_unreachable<T, V>(mut self, v: T) -> Self
    where
        T: std::iter::IntoIterator<Item = V>,
        V: std::convert::Into<std::string::String>,
    {
        use std::iter::Iterator;
        self.unreachable = v.into_iter().map(|i| i.into()).collect();
        self
    }
}

impl wkt::message::Message for ListResourceMaintenancesResponse {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.ListResourceMaintenancesResponse"
    }
}

#[doc(hidden)]
impl gax::paginator::internal::PageableResponse for ListResourceMaintenancesResponse {
    type PageItem = crate::model::ResourceMaintenance;

    fn items(self) -> std::vec::Vec<Self::PageItem> {
        self.resource_maintenances
    }

    fn next_page_token(&self) -> std::string::String {
        use std::clone::Clone;
        self.next_page_token.clone()
    }
}

/// The request structure for the GetResourceMaintenance method.
#[derive(Clone, Default, PartialEq)]
#[non_exhaustive]
pub struct GetResourceMaintenanceRequest {
    /// Required. The resource name of the resource within a service.
    pub name: std::string::String,

    pub(crate) _unknown_fields: serde_json::Map<std::string::String, serde_json::Value>,
}

impl GetResourceMaintenanceRequest {
    pub fn new() -> Self {
        std::default::Default::default()
    }

    /// Sets the value of [name][crate::model::GetResourceMaintenanceRequest::name].
    pub fn set_name<T: std::convert::Into<std::string::String>>(mut self, v: T) -> Self {
        self.name = v.into();
        self
    }
}

impl wkt::message::Message for GetResourceMaintenanceRequest {
    fn typename() -> &'static str {
        "type.googleapis.com/google.cloud.maintenance.api.v1.GetResourceMaintenanceRequest"
    }
}

/// The Category of the maintenance.
///
/// # Working with unknown values
///
/// This enum is defined as `#[non_exhaustive]` because Google Cloud may add
/// additional enum variants at any time. Adding new variants is not considered
/// a breaking change. Applications should write their code in anticipation of:
///
/// - New values appearing in future releases of the client library, **and**
/// - New values received dynamically, without application changes.
///
/// Please consult the [Working with enums] section in the user guide for some
/// guidelines.
///
/// [Working with enums]: https://google-cloud-rust.github.io/working_with_enums.html
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum MaintenanceCategory {
    /// Unspecified category.
    Unspecified,
    /// Infrastructure maintenance events are times that Google Cloud performs
    /// regular maintenance on network equipment e.g. Google Cloud Interconnect
    /// These events are usually scheduled in advance and we provide
    /// notification, when possible, so that users can plan for the
    /// infrastructure maintenance event and prevent downtime. Infrastructure
    /// maintenance events don't have a set interval between occurrences, but
    /// generally occur several times a year.
    Infrastructure,
    /// Updates that can include bug fixes, changes, or new features that are
    /// backward compatible with existing versions (including patches).
    /// Some SPs allow users to control the scheduling of these maintenance
    /// events using maintenance windows and/or deny maintenance features.
    ServiceUpdate,
    /// If set, the enum was initialized with an unknown value.
    ///
    /// Applications can examine the value using [MaintenanceCategory::value] or
    /// [MaintenanceCategory::name].
    UnknownValue(maintenance_category::UnknownValue),
}

#[doc(hidden)]
pub mod maintenance_category {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Clone, Debug, PartialEq)]
    pub struct UnknownValue(pub(crate) wkt::internal::UnknownEnumValue);
}

impl MaintenanceCategory {
    /// Gets the enum value.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the string representation of enums.
    pub fn value(&self) -> std::option::Option<i32> {
        match self {
            Self::Unspecified => std::option::Option::Some(0),
            Self::Infrastructure => std::option::Option::Some(1),
            Self::ServiceUpdate => std::option::Option::Some(3),
            Self::UnknownValue(u) => u.0.value(),
        }
    }

    /// Gets the enum value as a string.
    ///
    /// Returns `None` if the enum contains an unknown value deserialized from
    /// the integer representation of enums.
    pub fn name(&self) -> std::option::Option<&str> {
        match self {
            Self::Unspecified => std::option::Option::Some("MAINTENANCE_CATEGORY_UNSPECIFIED"),
            Self::Infrastructure => std::option::Option::Some("INFRASTRUCTURE"),
            Self::ServiceUpdate => std::option::Option::Some("SERVICE_UPDATE"),
            Self::UnknownValue(u) => u.0.name(),
        }
    }
}

impl std::default::Default for MaintenanceCategory {
    fn default() -> Self {
        use std::convert::From;
        Self::from(0)
    }
}

impl std::fmt::Display for MaintenanceCategory {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error> {
        wkt::internal::display_enum(f, self.name(), self.value())
    }
}

impl std::convert::From<i32> for MaintenanceCategory {
    fn from(value: i32) -> Self {
        match value {
            0 => Self::Unspecified,
            1 => Self::Infrastructure,
            3 => Self::ServiceUpdate,
            _ => Self::UnknownValue(maintenance_category::UnknownValue(
                wkt::internal::UnknownEnumValue::Integer(value),
            )),
        }
    }
}

impl std::convert::From<&str> for MaintenanceCategory {
    fn from(value: &str) -> Self {
        use std::string::ToString;
        match value {
            "MAINTENANCE_CATEGORY_UNSPECIFIED" => Self::Unspecified,
            "INFRASTRUCTURE" => Self::Infrastructure,
            "SERVICE_UPDATE" => Self::ServiceUpdate,
            _ => Self::UnknownValue(maintenance_category::UnknownValue(
                wkt::internal::UnknownEnumValue::String(value.to_string()),
            )),
        }
    }
}

impl serde::ser::Serialize for MaintenanceCategory {
    fn serialize<S>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        match self {
            Self::Unspecified => serializer.serialize_i32(0),
            Self::Infrastructure => serializer.serialize_i32(1),
            Self::ServiceUpdate => serializer.serialize_i32(3),
            Self::UnknownValue(u) => u.0.serialize(serializer),
        }
    }
}

impl<'de> serde::de::Deserialize<'de> for MaintenanceCategory {
    fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        deserializer.deserialize_any(wkt::internal::EnumVisitor::<MaintenanceCategory>::new(
            ".google.cloud.maintenance.api.v1.MaintenanceCategory",
        ))
    }
}
